package com.binance.zkconfig.config.condition;

import com.binance.zkconfig.app.constant.Constant;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * Created by Fei.Huang on 2018/8/29.
 */
public class EnableZkConfigCondition implements Condition {
    @Override
    public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
        String isOn = conditionContext.getEnvironment().getProperty(Constant.ZK_CONFIG_ENABLED);
        return null == isOn || isOn.length() == 0 || Constant.TRUE_LOWER.equals(isOn);
    }
}